home *** CD-ROM | disk | FTP | other *** search
- Path: realtime.net!usenet
- From: rflores@bga.com (Roberto Flores)
- Newsgroups: comp.lang.c++
- Subject: Need Help in using a DLL
- Date: 13 Mar 1996 04:57:33 GMT
- Organization: Real/Time Communications Internet customer posting
- Message-ID: <4i5kjt$bvb@news2.realtime.net>
- NNTP-Posting-Host: jake-4m.aip.realtime.net
- Mime-Version: 1.0
- X-RTcode: 8aa6f45731bd86255d4655df
- X-Newsreader: WinVN 0.93.11
-
- My background is UNIX/C w/ ESQL. but now I am developing for Windows
- 3.1. I am using MSVC++ 1.5. I have successfully used a DLL
- (GETENVAR.DLL) in a Powerbuilder application to retrieve values of DOS
- environment variables. I need to be able to do the same using 'C' ( I do not have
- the LIB file). Attached is the code I am using to do this. I maybe off base, so
- please help! I am building a quick working prototype using the MS QuickWin
- option. The code finds the DLL using the GetProcAddress
- function successfully, but I do not know to use the function. The
- function in the DLL I want to use is:
-
- GetEnvironmentVar("<Environment-Variable>", rtn_string);
-
- Code follows:
-
- #include <stdio.h>
- #include <windows.h>
-
- void main ()
- {
- void prtvar(char *text1);
-
- prtvar("USERID");
- }
-
- void prtvar(text1)
- char *text1;
- {
- char *rtn_envar;
- char *envar;
-
- HINSTANCE hinstGetEnVar;
- BOOL (FAR *lpfnGetEnvironmentVar);
-
- sprintf(envar, text1);
- printf("%s: ", envar);
- hinstGetEnVar = LoadLibrary("GETENVAR.DLL");
-
- if ( hinstGetEnVar > HINSTANCE_ERROR ) {
- (FARPROC) lpfnGetEnvironmentVar = GetProcAddress(hinstGetEnVar,
- "GetEnvironmentVar");
- if (lpfnGetEnvironmentVar != NULL ) {
-
- /* I need to use the function here. */
-
- printf("%s\n", rtn_envar );
- }
- else
- printf("Find Function Failed\n");
- }
- FreeLibrary( hinstGetEnVar );
- }
-
- Please help by replying to:
-
- rflores@bga.com or Robert.Flores@tpwd.state.tx.us
-
- Thanks A Bunch!
-
- Robert Flores
-
-
-
-
-